public class Solution {

    public int GetNumberOfK(int [] array , int k) {
       
        if (array.length == 0)  
            return 0;

        int l = 0;
        int r = array.length - 1;

        while(l <= r) {
            int mid = (l + r) / 2;
            if (array[mid] >= k) 
                r = mid - 1;
            else 
                l = mid + 1;
        }

        int num1 = l;
        System.out.printf("%d, %d", l, r);

        l = 0;
        r = array.length - 1;

        while(l <= r) {
            int mid = (l + r) / 2;
            if (array[mid] > k) 
                r = mid - 1;
            else 
                l = mid + 1;
        }

        int num2 = l;

        System.out.printf("%d, %d", l, r);

        return num2 - num1;

    }
}